#include <iostream>
#include <windows.h>
using namespace std;
#include "XThread.h"
static char *arr = NULL;
class MyThread :public XThread
{
public:
	int b = 0;
	int e = 0;
	void Main()
	{
		for (int i = b; i <= e; i++)
		{
			arr[i] = i;
		}
	}
};
int main()
{
	int size = 1000 * 1000 * 1000;
	arr = new char[size];
	int tsize = 16;
	MyThread *ths = new MyThread[tsize];

	long long start = GetTickCount();
	//for (int i = 0; i < size; i++)
	//{
	//	arr[i] = i;
	//}
	for (int i = 0; i < tsize; i++)
	{
		ths[i].b = i*(size / tsize);
		ths[i].e = ths[i].b + (size / tsize);
		if (ths[i].e >= size)
		{
			ths[i].e = size - 1;
		}
		ths[i].Start();
	}
	for (int i = 0; i < tsize; i++)
	{
		ths[i].Wait();
	}

	long long end = GetTickCount();
	cout <<"main deal ms = " <<end - start << endl;
	getchar();
	return 0;
}